<%@page import="java.util.Date"%>
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ include file="/WEB-INF/views/include.inc.jsp"%>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<head>
<script type="text/javascript">
function ajaxChange(obj)
{
	var programId=obj.value;
	var menuId=$("#menuId").val();
	//alert(programId+"---"+menuId);
	//return;
	if(obj.checked)
	{
		$.ajax({
			url:"${ctx}/module/distributeProgram",
			data:"programId="+programId+"&menuId="+menuId,
			cache:false,
			success:function()
			{
				navTab.reload();
			}
			
		});
	}
	else
	{
		$.ajax({
			url:"${ctx}/module/unDistributeProgram",
			data:"programId="+programId+"&fatherId="+menuId,
			cache:false,
			success:function()
			{
				navTab.reload();
			}
			
		});
	}
	
}
</script>
</head>
<div class=”layoutBox” id="menuProgram">
<form method="post" action="${ctx}/module/preDistributeProgram/${parentId}" onsubmit="return dialogSearch(this)">
	
	<div class="pageHeader">
		<div class="searchBar">
			<ul class="searchContent">
				<li>
					<label>模糊查询：</label>
					<input type="text" name="keywords" value="${keywords }"/>
				</li>
			</ul>
			<div class="subBar">
				<ul>						
					<li><div class="buttonActive"><div class="buttonContent"><button type="submit">查询</button></div></div></li>
				</ul>
			</div>
		</div>
	</div>
</form>
<form id="pagerForm" method="post" action="${ctx}/module/preDistributeProgram/${parentId}">
	<input type="hidden" name="pageNum" value="${page.pageNum}" />
	<input type="hidden" name="numPerPage" value="${page.numPerPage}" /> 
	<input type="hidden" name="orderField" value="${page.orderField}" />
	<input type="hidden" name="orderDirection" value="${page.orderDirection}" />
	 
	<input type="hidden" name="keywords" value="${keywords }"/>
</form>
	<table class="table" layoutH="138" width="100%">
		<thead>
			<tr>
				<th width="30">选择</th>
				<th width="100">程序编码</th>
				<th width="100">程序名称</th>
				<th width="100">程序URL</th>
				<th width="200">程序描述</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach var="item" items="${programList}">
			<tr target="slt_pid" rel="${item.id}">
				<td align="center">
				<c:if test="${fn:length(item.menuList)>1}">
				<c:set var="temp"></c:set>
				<c:forEach var="menu" items="${item.menuList }">
				<c:choose>
				<c:when test="${menu.parent.id!=null&&menu.parent.id eq parentId}">
				<c:set var="temp" value="checked"></c:set>
				</c:when>
				</c:choose>
				</c:forEach>
				<input type="checkbox" name="${item.strSn}" value="${item.id}" onclick="ajaxChange(this)" ${temp}/>
				</c:if>
				<c:if test="${fn:length(item.menuList)<=1}">
				<c:forEach var="menu" items="${item.menuList }">
				<c:choose>
				<c:when test="${menu.parent.id!=null&&menu.parent.id eq parentId}">
				<input type="checkbox" name="${item.strSn}" value="${item.id}" onclick="ajaxChange(this)" checked="checked"/>
				</c:when>
				<c:otherwise>
				<input type="checkbox" name="${item.strSn}" value="${item.id}" onclick="ajaxChange(this)"/>
				</c:otherwise>
				</c:choose>
				</c:forEach>
				</c:if>
				<c:if test="${fn:length(item.menuList)==0}">
				<input type="checkbox" name="${item.strSn}" value="${item.id}" onclick="ajaxChange(this)"/>
				</c:if>
				</td>
				<td>${item.strSn}</td>
				<td>${item.strName}</td>
				<td>${item.strUrl}</td>
				<td>${item.strDesc}</td>
			</tr>
			</c:forEach>
		</tbody>
	</table>
<input type="hidden" value="${parentId}" id="menuId">	
	<!-- 分页 -->
	<c:import url="/WEB-INF/views/pager/panelDialogBar.jsp"></c:import>
	<div class="formBar">
		<ul>
			<li><div class="button"><div class="buttonContent"><button type="button" class="close">关闭</button></div></div></li>
		</ul>
	</div>
	</div>
		
